# coding=utf-8
"""
@author: hyq
@time: 2019/8/5 20:43
"""
from db_fixture.mysql_db import DataBase, Event, Guest
from datetime import datetime

event1 = Event(id=1, name='红米Pro发布会', limit=2000, status=1, address='北京会展中心',
               start_time=datetime.strptime('2019-12-10 10:00:00', '%Y-%m-%d %H:%M:%S'),
               create_time=datetime.now())
event2 = Event(id=2, name='可参加人数为0', limit=0, status=1, address='北京会展中心',
               start_time=datetime.strptime('2019-9-10 10:00:00', '%Y-%m-%d %H:%M:%S'),
               create_time=datetime.now())
event3 = Event(id=3, name='当前状态为0关闭', limit=2000, status=0, address='北京会展中心',
               start_time=datetime.strptime('2019-9-10 10:00:00', '%Y-%m-%d %H:%M:%S'),
               create_time=datetime.now())
event4 = Event(id=4, name='发布会已结束', limit=2000, status=1, address='北京会展中心',
               start_time=datetime.strptime('2019-5-10 10:00:00', '%Y-%m-%d %H:%M:%S'),
               create_time=datetime.now())
guest1 = Guest(id=1, realname='ale', phone=13511001101, email='sign@163.com', sign=1, event_id=1,
               create_time=datetime.now())
guest2 = Guest(id=2, realname='has', phone=13511001102, email='sign@163.com', sign=1, event_id=2,
               create_time=datetime.now())
guest3 = Guest(id=3, realname='tom', phone=13511001103, email='sign@163.com', sign=1, event_id=3,
               create_time=datetime.now())
guest4 = Guest(id=4, realname='mao', phone=13511001104, email='sign@163.com', sign=1, event_id=4,
               create_time=datetime.now())
list_all = [event1, event2, event3, event4, guest1, guest2, guest3, guest4]


# 清空并插入新数据
def insertData():
    data = DataBase()
    data.delete_data(Guest)
    data.delete_data(Event)
    for i in list_all:
        data.add_data(i)


if __name__ == '__main__':
    insertData()
